package com.codemes.happylist.lucene.reader.pdf;

import com.itextpdf.text.pdf.parser.ImageRenderInfo;
import com.itextpdf.text.pdf.parser.RenderListener;
import com.itextpdf.text.pdf.parser.TextRenderInfo;

/**
 * @author <a href="mail:fulei@fehorizon.com">fulei</a>
 * @date 2022/8/22 19:22
 */
public class PdfPageContentReadListener implements RenderListener {

    StringBuilder sb = new StringBuilder();

    @Override
    public void beginTextBlock() {
        // DO NOTHING
    }

    @Override
    public void renderText(TextRenderInfo textRenderInfo) {
        String content = textRenderInfo.getText().trim();
        sb.append(content);
    }

    @Override
    public void endTextBlock() {
        // DO NOTHING
    }

    @Override
    public void renderImage(ImageRenderInfo imageRenderInfo) {
        // DO NOTHING
    }

    public String getAllContent(){
        return sb.toString();
    }
}
